<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>通用SQL查询</title>
	<link href="../../css/component.css" rel="stylesheet" type="text/css" />
</h:head>

<ui:param name="bean" value="#{sqlQueryAction}" />
<h:body>
	<span class="pagetitle">系统配置 —— 通用查询</span>
	<p:separator />	

	<h:form id="fsearch"> 
		<p:messages id="messages" showDetail="true" autoUpdate="true"  /> 
		<p:dataTable var="gp" value=""  resizableColumns="true">		
			<p:column width="5%" />			
			<p:column headerText="查询SQL语句" style="text-align:center" width="80%" >
				<p:inputTextarea id="sqls" value="#{bean.sql}"      rows="3" cols="80" maxlength="500" autoResize="true" />
			</p:column>			
			<p:column headerText="操作" style="text-align:center" width="10%" >
				<p:commandButton value="查询" action="#{bean.search()}" update=":fresult,:fsearch" ajax="true"/>
				<p:commandButton  id="export" value="导出" action="#{bean.saveAsCsv()}"	rendered="#{bean.hasData}"	ajax="false"	/>	
			</p:column>			
			<p:column width="5%" />
		</p:dataTable>
	</h:form>

	<br />
	<h:form id="fresult">
		<p:outputPanel id = "foutpanel">
			<p:panel id = "fpanel" header="查询结果" rendered="#{bean.hasData}" style="text-align:center;" >
				<p:dataTable value="#{bean.dataList}" var="item" resizableColumns="true" paginator="true" rows="20" >
					<p:columns value="#{bean.columnNames}" var="columnName" columnIndexVar="i" style="text-align:center;">
						<f:facet name="header">#{columnName}</f:facet>
						#{item[i]}
					</p:columns>
				</p:dataTable>
			</p:panel>
		</p:outputPanel>
	</h:form>
</h:body>
</html>
